#pragma once
#include<graphics.h>
#pragma   comment(lib,"Msimg32.lib")

void my_putimage(int x, int y , IMAGE* img)
{
	int w = img->getwidth();
	int h = img->getheight();

	AlphaBlend(GetImageHDC(NULL), x, y, w, h, GetImageHDC(img), 0, 0, w, h, { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA });
}

void flip_image(IMAGE* src, IMAGE* dest)
{
	int w = src->getwidth();
	int h = src->getheight();
	Resize(dest, w, h);
	DWORD* src_buff = GetImageBuffer(src);
	DWORD* dest_buff = GetImageBuffer(dest);
	for (size_t i = 0; i < h; i++)
	{
		for (size_t j = 0; j < w; j++)
		{
			int index_src = i * w + (w - 1 - j);
			int index_dest = i * w + j;
			dest_buff[index_dest] = src_buff[index_src];
		}
	}

}

void flip_atlas(Atlas& src, Atlas& dest)
{
	dest.clear();
	for (size_t i = 0; i < src.get_size(); i++)
	{
		IMAGE dest_image;
		flip_image(src.get_image(i), &dest_image);
		dest.add_image(dest_image);
	}
}